#include <iosfwd>

#include "abstractwc.h"

WordCounter::WordCounter(std::string const & file) : file_(file), counter_(0), time_(0)
{
}

bool WordCounter::wasModified()
{
    boost::filesystem::path path(file_.c_str());
    if (boost::filesystem::exists(path))
    {
        std::time_t t = boost::filesystem::last_write_time(path);
        if (t > time_)
        {
            time_ = t;
        return true;
        }
    }
    return false;
}


NewWord::NewWord() : last_state_(false) {}

bool NewWord::operator() (char c)
{
    bool current_state = (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' ||
                            (c >= '0' && c <= '9') || (c == '_' || c == '-' || c == '.') && last_state_);
    bool result = (!last_state_) ? (last_state_ != current_state) : false;
    last_state_ = current_state;
    return result;
}
